import http from "@/utils/http"

const baseUrl = "/active"

export interface ActiveDto {
    id?: number,
    activeTitle: string,
    activeStartTime: string,
    activeDeadline: string,
    activeHeadImg: OssFile[] | string,
    activeInstance: OssFile[] | string
    instanceOssIds: string,
    activeAddr: string,
    activeLabel?: string[] | string,
    activePrice: number,
    activeOriginPrice?:number,
    activeAim?: string,
    activeTrip: trip[] | string,
    activeTargetGroup: string,
    activeRegisterDeadline: string,
    activeLimit: number,
    updateBy: string,
    status: 3
}

export interface ActiveListVo {
    id?: number,
    activeTitle: string,
    activeStartTime: string,
    activeDeadline: string,
    activeAddr: string,
    activePrice: number,
    activeOriginPrice?:number,
    activeLimit: number,
    updateBy: string,
    status: 0
}

export interface ActiveVo {
    id?: number,
    activeHeadImg: OssFile[],
    activeTitle: string,
    activeStartTime: string,
    activeDeadline: string,
    activeAddr: string,
    activeLabel?: string | string[],
    activePrice: number,
    activeOriginPrice?:number,
    activeInstance: OssFile[],
    activeAim?: string,
    activeTrip: trip[] | string,
    activeTargetGroup: string,
    activeRegisterDeadline: string,
    activeLimit: number,
    updateBy: string,
    status: 0
}

export interface trip {
    id: string,
    time: string,
    content: string,
    order?: number
}

export interface OssFile {
    ossId: string,
    fileType: string
    clientUrl: string,
}

export interface Query {
    title: string,
    startDate: string,
    deadlineDate:string,
    addr:string,
    pageNum: number,
    pageSize:number,
    total?:number
}


export interface GuestsWxVo {
    avatar: string;
    name: string;
}

export interface ActiveFormWxVo {
    name: string;
    tableColumnType: string;
    placeholder?: string;
    label: string;
    inputType: string;
    optionValue?: any;
}

export interface ActiveDetailVo {
    id: number;
    activeTitle: string;
    activeBegin: string;
    activeEnd: string;
    bannerList: OssFile[];
    activeAddr: string;
    activeLabel: string;
    activePrice: number;
    activeOriginPrice?: number;
    activeInstance: OssFile[]; // 实例文件列表
    activeAim?: string;
    activeTrip: string;        // 行程安排（后端返回字符串）
    guests: GuestsWxVo[];      // 嘉宾列表
    activeRegisterDeadline: string;
    activeTargetGroup: string;
    activeLimit: number;
    activeRegisteredNum: number; // 已报名人数
    activeForm: ActiveFormWxVo[]; // 活动表单
}


/**
 * 新增
 * @param active
 */
export function addActive(active:ActiveDto) {
    return http.post(`${baseUrl}`, active)
}

/**
 * 修改
 * @param active
 */
export function putActive(active:ActiveDto) {
    return http.put(`${baseUrl}`,active)
}

/**
 * 上传图片
 */
export function uploadActiveImg(file:FormData) {
    return http.put(`${baseUrl}/head_img`, file)
}

/**
 * 删除实例
 * @param id
 * @param userId
 * @param ossIds
 */
export function delActiveInstanceFile(id: number, userId: string, ossIds:string) {
    return http.del(`${baseUrl}/instance?id=${id}&userId=${userId}&ossIds=${ossIds}`)
}



/**
 * 查询列表
 */
export function getActiveListVo(query:Query) {
    return http.post(`${baseUrl}/get`, query)
}

/**
 * 查询详情
 */
export function getActiveIdVo(id:string) {
    return http.get(`${baseUrl}/${id}` )
}


export function delActive(id: string) {
    return http.del(`${baseUrl}/${id}`)
}

export function getActiveDetail(id: string) {
    return http.get(`${baseUrl}/de/${id}`)
}